package AndroidHT.Workspace;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class WelcomeActivity extends Activity {

	public static String Welcome = "Welcome:";
	
	/** Called when the activity is first created. */
    Context appContext;
	
	
	@Override
	public void onCreate(Bundle savedInstanceState) {

		
		Log.i(Welcome,"Dentro OnCreate");
		
		appContext = this.getApplicationContext();
		
		super.onCreate(savedInstanceState);	
	    setContentView(R.layout.welcome);    

	    Log.i(Welcome,"Dentro Content");
	    
	    Button button = (Button) findViewById(R.id.buttonIngresar);
	   
	    button.setOnClickListener(new OnClickListener()
	    {     

			public void onClick(View v) {
				
				Log.i(Welcome,"Dentro OnClick");
				
				SharedPreferences settings = getSharedPreferences("HT",MODE_PRIVATE);			   
				SharedPreferences.Editor editor = settings.edit();
			    EditText mail = (EditText) findViewById(R.id.editTextMail);
			    
			    Toast.makeText(appContext,"Mail ingresado: "+mail.getText().toString(),Toast.LENGTH_SHORT).show();
			  
			    
			    editor.putString("HT_Start", "OK" );	
			    
				editor.putString("HT_Email", mail.getText().toString() );
				editor.commit();
				
				startActivity(new Intent(appContext,AndroidHTActivity.class));
				
			}
	    });
	 
	}
	@Override
	protected void onStop() {
		
		super.onStop();
	}
}
